package pack.projectiles;

import com.jme.math.Vector3f;
import com.jme.scene.Controller;
import com.jme.scene.TriMesh;

public class LumenMover extends Controller 
{
    private static final long serialVersionUID = 1L;
    
    TriMesh bullet;

    Vector3f direction;

    float speed = 10;

    float lifeTime = 5;

    public LumenMover(TriMesh bullet, Vector3f direction) {
        this.bullet = bullet;
        this.direction = direction;
        this.direction.normalizeLocal();
    }

    public void update(float time) 
    {
        lifeTime -= time;
        if (lifeTime < 0) {
            //rootNode.detachChild(bullet);
            bullet.removeController(this);
            return;
        }
        Vector3f bulletPos = bullet.getLocalTranslation();
        bulletPos.addLocal(direction.mult(time * speed));
        bullet.setLocalTranslation(bulletPos);
        
    }

}
